// pages/orders/order_detail/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    order_number: 0,
    address: [],
    order: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options);
    // 获取订单列表
    let orders = wx.getStorageSync("orders");
    // console.log(orders);
    let order = orders.filter((v) => v.order_number == options.order_number)[0];
    // console.log(order);
    let address = {
      order_address:
        order.address.provinceName +
        order.address.cityName +
        order.address.countyName +
        order.address.detailInfo,
      userName: order.address.userName,
      telNumber: order.address.telNumber,
    };
    // console.log(address);
    this.setData({
      address,
      order,
      order_number:options.order_number
    });
  },
  // 支付功能
  handlePay() {
    // console.log(this.data.order_number);
    const num = this.data.order_number
    let orders = wx.getStorageSync('orders');
    orders = orders.filter(v=>v.order_number==num?v.type=2:v)
    // console.log(orders);
    this.setData({
      order:orders.filter(v=>v.order_number==num)[0]
    })
    wx.setStorageSync('orders', orders)
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
